﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace MiddlewareCore.Middleware
{
    public delegate Task RequestDelegate(MiddlewareContext context);
    /// <summary>
    /// 实现此抽象类可实现一个中间件操作
    /// </summary>
    public abstract class IMiddleware
    {
        public IMiddleware(RequestDelegate next) { }
        /// <summary>
        /// 中间件业务执行；
        /// 若要执行下一个中间件，请执行next对应方法
        /// </summary>
        /// <param name="context">中间件上下文，包含一次请求回复</param>
        /// <returns></returns>
        public abstract Task Invoke(MiddlewareContext context);
    }
}
